package com.caac.core.dm;

import com.caac.core.config.ActionConf;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright lianzs 2004</p>
 * <p>Company: lianzs</p>
 * @author <a href="mailto:lianzs@agilecentury.com.cn">lianzs</a>
 * @version 1.0
 */

public class Permission extends BaseDm {
    private String id;
    private Integer moduleCode;
    private String moduleName;
    private String moduleDesc;

    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getModuleCode() {
        return moduleCode;
    }

    public void setModuleCode(Integer moduleCode) {
        this.moduleCode = moduleCode;
    }

    public String getModuleName() {
        return moduleName;
    }

    public String getModuleDesc() {
        return moduleDesc;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }

    public void setModuleDesc(String moduleDesc) {
        this.moduleDesc = moduleDesc;
    }

    protected int doHashCode() {
        return getHashCodeBuilder().append(id).toHashCode();
    }

    protected boolean doEquals(Object object) {
        Permission other = (Permission) object;
        return getEqualsBuilder().append(id, other.id).isEquals();
    }

    public boolean isAccessible(ActionConf actionConf) {
        return moduleName.equals(actionConf.getKey());
    }
}
